package uy.edu.fing.signeo.configuracion;

import es.unex.sextante.core.GeoAlgorithm;
import es.unex.sextante.core.Sextante;
import es.unex.sextante.dataObjects.IRasterLayer;
import es.unex.sextante.rasterWrappers.GridExtent;

public class Raster4BandasAlgorithm extends GeoAlgorithm{
	
	protected double m_dValue;
	public static final String RESULT = "RESULT";
	protected final double NO_DATA = -99999.0;
	
    public void defineCharacteristics(){
    	
     	this.setGroup(Sextante.getText("Incendios"));
 		this.setName(Sextante.getText(new String("Prueba Raster 4 Bandas")));
 		setGeneratesUserDefinedRasterOutput(false);
 		
		addOutputRasterLayer(RESULT, "Raster de 4 bandas con color");

    }
    
    public boolean processAlgorithm() {
    	try {
    		
    		GridExtent gridExtent = new GridExtent();
    		gridExtent.setCellSize(1);
    		gridExtent.setXRange(0, 2);
    		gridExtent.setYRange(0, 2);
    		
    		IRasterLayer result = getNewRasterLayer(RESULT, "Raster de 4 bandas", IRasterLayer.RASTER_DATA_TYPE_DOUBLE, gridExtent, 4);
    		
    		//BANDA 0 (RED)
    		result.setCellValue(0, 0, 0, 0);
    		result.setCellValue(1, 0, 0, 255);
    		result.setCellValue(0, 1, 0, 255);
    		result.setCellValue(1, 1, 0, 0);
    		
    		//BANDA 1 (GREEN)
    		result.setCellValue(0, 0, 1, 255);
    		result.setCellValue(1, 0, 1, 255);
    		result.setCellValue(0, 1, 1, 0);
    		result.setCellValue(1, 1, 1, 0);
    		
    		//BANDA 2 (BLUE)
    		result.setCellValue(0, 0, 2, 0);
    		result.setCellValue(1, 0, 2, 0);
    		result.setCellValue(0, 1, 2, 0);
    		result.setCellValue(1, 1, 2, 255);
    		
    		//BANDA 3 (Indice)
    		result.setCellValue(0, 0, 3, 1);
    		result.setCellValue(1, 0, 3, 2);
    		result.setCellValue(0, 1, 3, 3);
    		result.setCellValue(1, 1, 3, 4);
    		
    		/*
    		 * switch (indice){
    		  	case (indice < 34):{
    			 	result.setCellValue(x,y,0, 0);
    		 		result.setCellValue(x,y,1, 255);
    				result.setCellValue(x,y,2, 0);
    				result.setCellValue(x,y,3, indice);
    		  		break;
    		 		}
    		  	case (indice < 67):{
    			 	result.setCellValue(x,y,0, 255);
    		 		result.setCellValue(x,y,1, 0);
    				result.setCellValue(x,y,2, 0);
    				result.setCellValue(x,y,3, indice);
    		  		break;
    		 		}
    		  	default: {
    			 	result.setCellValue(x,y,0, 0);
    		 		result.setCellValue(x,y,1, 0);
    				result.setCellValue(x,y,2, 255);
    				result.setCellValue(x,y,3, indice);
    		  		break;
    		 		}
    		 }
    		 * 
    		 */
    		// result.setCellValue(x,y,0, valorColorR);
    		// result.setCellValue(x,y,1, valorColorV);
    		// result.setCellValue(x,y,2, valorColorA);
    		// result.setCellValue(x,y,3, indice);
    		
    		return !m_Task.isCanceled();
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    	}	

    	return !m_Task.isCanceled();

    }
    

}
    


	